

enum GraphicsOperator {
    Rect = 'rect',
    Arc = 'arc',
    Text = 'text'
}



class Graphics {
    ctx: CanvasRenderingContext2D;
    constructor(ctx: CanvasRenderingContext2D) {
        this.ctx = ctx
    }
    paintRect(x: number, y: number, width: number, height: number, options: { isFill?: boolean, fillStyle?: string, strokeStyle?: string } = {}) {
        this._clearRect(x, y, width, height);
        const { isFill = false, fillStyle = '#aaa', strokeStyle = '#aaa' } = options;
        if (isFill) {
            this._fillRect(x, y, width, height, fillStyle);
        } else {
            this._strokeRect(x, y, width, height, strokeStyle)
        }
    }

    _clearRect(x: number, y: number, width: number, height: number) {
        this.ctx.clearRect(x, y, width, height);
    }

    drawImage(image, x, y, width, height) {
        this._clearRect(x, y, width, height);
        this.ctx.drawImage(image, x, y, width, height)
    }

    private _fillRect(x: number, y: number, width: number, height: number, fillStyle: string | CanvasGradient | CanvasPattern) {
        this.ctx.fillStyle = fillStyle;
        this.ctx.fillRect(x, y, width, height);
        console.log(fillStyle);


    }
    private _strokeRect(x: number, y: number, width: number, height: number, strokeStyle: string | CanvasGradient | CanvasPattern) {
        this.ctx.strokeStyle = strokeStyle
        this.ctx.strokeRect(x, y, width, height);
    }


}


export default Graphics